import debounce from "lodash/debounce";
//@ts-ignore
import { hashrouter } from "./hashrouter";
import { scrolltoelementid } from "./scrolltoelementid";
//@ts-ignore
export { anchorscroll };
const anchorscroll = debounce(function anchorscroll() {
    const params = hashrouter.getparams();

    if (Reflect.has(params, "id")) {
        const id = Reflect.get(params, "id");
        if (id === "top") {
            scrollTo(0, 0);
        } else if (id === "bottom") {
            scrollTo(0, document.body.scrollHeight);
        } else {
            scrolltoelementid(id);
        }
    } else {
        window.scrollTo(0, 0);
    }
});
